<%@ page language="java" import="java.util.*,com.model.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  	<%
	  ArrayList<Beanuser> al=new ArrayList<Beanuser>();
	  locationBO lbo=new locationBO();
	  al=lbo.getLocation();
     %>   
    <base href="<%=basePath%>">
    
    <title>My JSP 'uerManage.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	
	<script>

function userCheck() {
  var device = document.former.device.value;
  var id = document.former.stuid.value;
  var name = document.former.name.value;
  var pwd = document.former.pwd.value;
  var tel = document.former.tel.value;
  var age = document.former.age.value;
  var patrn=/^[A-Za-z0-9]+$/; 
  var shuzi=/^[0-9]+$/;
  var han=/^[\u4e00-\u9fa5]+$/;
  var   http_request= false;
  if(device=="") {
  alert("设备号不能为空！");
  return false;
  }
  else if(!patrn.exec(device)){
  alert("设备号只能由26个英文字母和数字组成！");
  return false;}
  else if(id==""){
  alert("学号不能为空！");
   return false;}
   else if(!shuzi.exec(id)){
  alert("学号只能由数字组成！");
  return false;}
   else if(name==""){
  alert("姓名不能为空！");
   return false;}
   else if(pwd==""){
  alert("密码不能为空！");
   return false;}
  else if(!patrn.exec(pwd)){
  alert("密码只能由26个英文字母和数字组成！");
  return false;}
  else if(!han.exec(name)){
  alert("姓名只能由汉字组成！");
  return false;}
  else {
  var ur="regisCheck?uname="+device
  
   sendRequest(ur);
   return false;
  }
}

 //创建XMLHttpRequest对象       
    function createXMLHttpRequest() {
  if(window.XMLHttpRequest) { //Mozilla 浏览器
   XMLHttpReq = new XMLHttpRequest();
  }
  else if (window.ActiveXObject) { // IE浏览器
   XMLHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
 //发送请求函数
 function sendRequest(url) {
  createXMLHttpRequest();
  XMLHttpReq.open("GET", url, true);
  XMLHttpReq.onreadystatechange = processResponse;//指定响应函数
  XMLHttpReq.send(null);  // 发送请求
 }
 // 处理返回信息函数
    function processResponse() {
     if (XMLHttpReq.readyState == 4) { // 判断对象状态
         if (XMLHttpReq.status == 200) { // 信息已经成功返回，开始处理信息
       var data = XMLHttpReq.responseText;  
        //将数据显示在页面上   
       var divNode = document.getElementById("result");     
       //设置元素节点中的html内容   
        divNode.innerHTML = data;
            idresult(data);
            } else { //页面不正常
                alert("您所请求的页面有异常。"+XMLHttpReq.status);
            }
        }
    }
 function idresult(ab){
 if(ab==1){
 document.former.submit();}
 }

</script>

  </head>

  <body>
  <DIV  style="width:900px;
  height:300px;
  margin:0 auto;
  border:1px solid #ccc;">
  <DIV style="width:400px;
 height:300px;
 float:left;
 background:#eee;">
<DIV id=u43_rtf><p style="text-align:center;"><span style="font-family:Arial;font-size:20px;font-weight:bold;font-style:normal;text-decoration:none;color:#333333;">学生信息查看</span></p></DIV>


<table>
<tr>
<td width=15%>姓名</td>
<td width=15%>学号</td>
<td width=15%>年龄</td>
<td width=25%>电话</td>
</tr>
<% 	for(int i= 0;i<al.size();i++)
	 {
	     Beanuser lt=(Beanuser)al.get(i);
%>
<tr>
<td><%=lt.getName()%></td>
<td><%=lt.getAge()%></td>
<td><%=lt.getId()%></td>
<td><%=lt.getTel()%></td></tr>
<%
}
%>
<tr><td colspan="4" align=center>
<!--<form name="former" action="admin/info2.jsp" target="contentmap">
<INPUT id=u38 type=button onclick="submit()"    value="刷新信息"  style="width: 150px;height: 30px">
</form>
--></td></tr>
</table>
</DIV>
<DIV align=left style="width:498px;
 height:100px;
 float:right;
 background:#eef;">
 <form name=former method=post action=regis >
<table>
<tr><td>请输入设备号 </td>  <td> <input name=device>
<div id="result" style="color:red" ></div> </td></tr>
<tr><td>请输入学号   </td>     <td>  <input name=stuid></td></tr>
<tr><td>请输入姓名    </td>   <td>   <input name=name></td></tr>
<tr><td>请输入密码    </td>    <td>  <input name=pwd></td></tr>
<tr><td>请输入电话号码</td><td><input name=tel></td></tr>
<tr><td>请输入年龄     </td>   <td>  <input name=age></td>
</tr></table>
<input type=button value="注   册" onclick="userCheck()"></form>
</DIV>
</DIV>
  </body>
</html>
